﻿@*
@model IEnumerable<Core.Models.User>
*@

@{
    ViewBag.Title = "Index";
    Guid BusinessUnitId = (Guid)ViewData["BusinessUnitId"];
}

<h2>User Administration for @ViewData["BusinessUnitName"].ToString()</h2>

<p>
    @Html.ActionLink("Create New", "Create", new { id = BusinessUnitId})
</p>
@Html.Hidden("hdnBusinessUnitId",ViewData["BusinessUnitId"].ToString())
<div id="dynamic">
<table id="tblUser" cellspacing="0" cellpadding="10" width="100%" >
<thead>
    <tr>
        <th></th>
        <th>
            Name
        </th>
        <th>
            Email
        </th>
        <th>
            Approved?
        </th>
        <th>
            Locked Out?
        </th>
        <th>
            Last Activity
        </th>
    </tr>
</thead>
<tbody>
	<tr>
		<td colspan="7" class="dataTables_empty">Loading data from server</td>
	</tr>
</tbody>
</table>
</div>
<div class="spacer"></div>
<script type="text/javascript" language="javascript">
$(function () {
    $('#tblUser').dataTable({
		"aoColumnDefs": [
            { "bSortable": false, "aTargets": [ 0 ] },
			{ "sClass": "nowrap", "aTargets": [0] },
            { "sWidth": "160px", "aTargets": [0] },

            { "bSortable": false, "aTargets": [1] },
			{ "sClass": "nowrap", "aTargets": [1] },
            { "sWidth": "94%", "aTargets": [1] },
			{ "sName": "name", "aTargets": [1] },

            { "bSortable": false, "aTargets": [2] },
            { "sWidth": "1%", "aTargets": [2] },
			{ "sName": "email", "aTargets": [2] },

            { "bSortable": false, "aTargets": [3] },
			{ "sClass": "centercell", "aTargets": [3] },
            { "sWidth": "1%", "aTargets": [3] },
			{ "sName": "isapprovedyn", "aTargets": [3] },

            { "bSortable": false, "aTargets": [4] },
			{ "sClass": "centercell", "aTargets": [4] },
            { "sWidth": "1%", "aTargets": [4] },
			{ "sName": "islockedoutyn", "aTargets": [4] },

            { "bSortable": false, "aTargets": [5] },
            { "sWidth": "1%", "aTargets": [5] },
			{ "sName": "lastactivitydt", "aTargets": [5] }
		],
        "sPaginationType": "full_numbers",
        "iDisplayLength": 15,
        "aLengthMenu": [[15, 25, 50], [15, 25, 50]],
        "bStateSave": true,
        "bJQueryUI": true,
		"bProcessing": true,
		"bServerSide": true,
		"sAjaxSource": "/User/UserList",
		"fnServerData": function ( sSource, aoData, fnCallback ) {
		    aoData.push({ "name": "BusinessUnitId", "value": $("#hdnBusinessUnitId").val() });
		    $.ajax({
				"dataType": 'json', 
				"type": "POST", 
				"url": sSource, 
				"data": aoData, 
				"success": fnCallback
			} );
		}
	} );
} );
</script>
